<?php

/*
 * @author Ebrain Cedeno <ebraincedeno@gmail.com>
 */

class TButton extends TWidget{
    
    public $Disabled;
    public $Type="submit";
    public $onClick = '';
    public $Value;
    
    public function __construct($textButton='submit') {
        parent::__construct(__CLASS__);
        $this->Value = $textButton;
    }
    
    protected function OnClick(){
        if ($this->onClick != ""){
            
            return '<script type="text/javascript">
                        $(document).ready(function(){
                            $("#'.$this->Id.'").click(function(event){
                                '.$this->onClick.'
                            });
                        });
                    </script>';
        }
    }
    
    public function show(){
        
        if (!array_key_exists('style', $this->OptionsAditional)){
            $this->OptionsAditional['style'] = array('width:'.$this->Width.'px','height:'.$this->Height.'px');
        }
        else{
            $this->OptionsAditional['style'][] = 'width:'.$this->Width.'px';
            $this->OptionsAditional['style'][] = 'height:'.$this->Height.'px';
        }
        
        if ($this->Visible == true){
            
            $html = '<input name="'.$this->Name.'" id="'.$this->Id.'" type="'.$this->Type.'" value="'.$this->Value.'" '.$this->getOptionsAditional().' />'."\n";
            $html .= $this->OnClick();
            
            return $html;
        }
        else{
            return '';
        }
    }
    
}

?>
